package com.food.platformmanagement.adapter.inbound;

import com.food.platformmanagement.domain.User;
import com.food.platformmanagement.port.inbound.MemberUseCase;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 暂时废弃此类
 * 使用UserController类
 * @author 24270
 */
@RestController
@RequestMapping(value = "/auditor")
@CrossOrigin("*")
public class AuditorController {
    private final MemberUseCase useCase;

    @Autowired
    public AuditorController(MemberUseCase useCase) {
        this.useCase = useCase;
    }

    @GetMapping("/getAll")
    public List<User> getAll() {
        return useCase.getAllAuditor();
    }

    @GetMapping("/getOne/{id}")
    public User getOne(@PathVariable String id) {
        return useCase.getTheAuditor(id);
    }

    @PostMapping("/add/{name}/{password}")
    public String add(@PathVariable String name, @PathVariable String password) {
        return useCase.addAuditor(name, password);
    }

    @PostMapping("/delete/{id}")
    public boolean delete(@PathVariable String id) {
        return useCase.deleteAuditor(id);
    }
}
